home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_com_submachine.cog < prev    next >
Text File  |  1999-11-15  |  4KB  |  177 lines

  1. # Jones 3D Cog Script
  2. #
  3. # com_Submachine.cog
  4. #
  5. # This COG controls the PPSH-41 submachine gun for bad guys.
  6. #
  7. # [RandyT]
  8. #
  9. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  10. #
  11. # ===================================================================
  12.  
  13. symbols
  14.  
  15. message        fire
  16. message        aim
  17. message        activated
  18. message        deactivated
  19. message        selected
  20. message        deselected
  21.  
  22. sound        bang=gen_submachine_fire.wav    local    # Autoloaded
  23.  
  24. template    projectile=+submachine            local    # Autoloaded
  25. template    smoke1=+pistol_smoke1            local    # Autoloaded
  26. template    smoke2=+pistol_smoke2            local    # Autoloaded
  27.  
  28. thing        bandito                            local
  29. thing        bullet                            local
  30.  
  31. flex        aimFOV=25.0                        local
  32. flex        aimMax=5.0                        local
  33. flex        aimWait=0.3                        local
  34. flex        fireWait=0.2                    local
  35.  
  36. int            numFires=0                        local
  37.  
  38. vector        firePos                            local
  39.  
  40. end
  41.  
  42. # ===================================================================
  43. code
  44.  
  45. # -------------------------------------------------------------------
  46. fire:
  47.  
  48.     bandito = GetSourceRef();
  49.  
  50.     # If he's done firing, deactivate the weapon
  51.     numFires = GetThingUserData(bandito);
  52.     if (numFires == 0)
  53.     {
  54.         DeactivateCurWeapon(bandito);
  55.         return;
  56.     }
  57.  
  58.     firePos = GetThingJointPos(bandito, GetNodeByName(bandito, "inrhand"));
  59.     bullet = FireProjectile(bandito, projectile, bang, 66, firePos, '0 0 0', 1.0, 0x220, aimFOV, aimMax);
  60.  
  61.     if (bullet == -1) return;
  62.  
  63.     if ( !IsThingModelName(bandito, "com_tr.3do") )
  64.     {
  65.         if (Rand() < 0.5) CreateThing(smoke1, bullet);
  66.         else CreateThing(smoke2, bullet);
  67.     }
  68.  
  69.     SetFireWait(bandito, fireWait);
  70.  
  71.     # Set the number of shots left
  72.     numFires = numFires - 1;
  73.     SetThingUserData(bandito, numFires);
  74.  
  75.     return;
  76.  
  77.  
  78. # -------------------------------------------------------------------
  79. aim:
  80.  
  81.     bandito    = GetSourceRef();
  82.  
  83.     if ( IsModePlaying(bandito, 62) == 0 )                        # Weapon drawn?
  84.         return;
  85.  
  86.     if ( GetParam(0) )                                            # Got target?
  87.     {
  88.         if ( IsModePlaying(bandito, 63) == 0 )                    # Not aiming yet?
  89.         {
  90.             PlayMode(bandito, 63, 0);                            # Play "aiming" anim
  91.             SetAimWait(bandito, aimWait);
  92.         }
  93.     }
  94.     else
  95.     {
  96.         if ( IsModePlaying(bandito, 63) > 0 )                    # Currently aiming?
  97.         {
  98.             if ( IsThingModelName(bandito, "com_2G.3do") )        # Bruiser is one-handed -- no unaim
  99.             {
  100.                 StopMode(bandito, 63, aimWait);                    # Stop aiming
  101.             }
  102.             else
  103.             {
  104.                 StopMode(bandito, 63, aimWait);                    # Stop aiming
  105.                 PlayMode(bandito, 68, 0);                        # Play "stop aiming" anim
  106.                 SetAimWait(bandito, aimWait);
  107.             }
  108.         }
  109.     }
  110.  
  111.     return;
  112.  
  113.  
  114. # -------------------------------------------------------------------
  115. activated:
  116.  
  117.     bandito = GetSourceRef();
  118.  
  119.     SetThingUserData(bandito, 3); 
  120.     ActivateWeapon(bandito, aimWait);
  121.  
  122.     return;
  123.  
  124.  
  125. # -------------------------------------------------------------------
  126. deactivated:
  127.  
  128.     bandito = GetSourceRef();
  129.  
  130.     SetThingUserData(bandito, 0); 
  131.     DeactivateWeapon(bandito);
  132.  
  133. return;
  134.  
  135.  
  136. # -------------------------------------------------------------------
  137. selected:
  138.  
  139.     bandito = GetSourceRef();
  140.  
  141.     SetArmedMode(bandito, 4);
  142.  
  143.     if ( IsThingModelName(bandito, "com_tr.3do"))
  144.     {
  145.         SetThingFireOffset(bandito, '-0.005 -0.02 0.008');
  146.     }
  147.     else if (IsThingModelName(bandito, "com_mc.3do") )
  148.     {
  149.         SetThingFireOffset(bandito, '-0.000 -0.00 0.008');
  150.     }
  151.     else
  152.     {
  153.         SetThingFireOffset(bandito, '-0.005 0.05 0.008');
  154.         PlayMode(bandito, 62, 0);                                # Play "draw weapon" anim
  155.     }
  156.  
  157.     return;
  158.  
  159.  
  160. # -------------------------------------------------------------------
  161. deselected:
  162.  
  163.     bandito = GetSourceRef();
  164.  
  165.     if ( !IsThingModelName(bandito, "com_tr.3do") && !IsThingModelName(bandito, "com_mc.3do") )
  166.     {
  167.         StopMode(bandito, 62, 0);                                # Stop "draw weapon" anim
  168.         StopMode(bandito, 63, 0);                                # Stop "aiming" anim
  169.     }
  170.  
  171.     SetArmedMode(bandito, 0);
  172.     SetThingFireOffset(bandito, '0 0 0');
  173.  
  174.     return;
  175.  
  176. end
  177.